
import 'package:flutter/material.dart';
import 'dart:ui';
export 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:page_transition/page_transition.dart';
/// 
/// 
/// 
/// 是否是发布版本
/// 
/// 
/// 
const bool APP_IS_RELEASE = true;

//融云 appkey
const String RongAppKey = 'k51hidwq18tgb';
//用户 id
const String CurrentUserId = 'userid1';

// 是否是第一次登陆app
const String KEY_is_first_app = "KEY_is_first_app";
const String KEY_user_token = "KEY_user_token";

// 用户基本数据json
const String KEY_userjosn_info = "KEY_userjosn_info";

// 用户基础照片墙
const String KEY_user_background = "KEY_user_background";

// 系统默认数据
const String KEY_SYS_Data = "KEY_SYS_Data";

// 特别关心提示音量
const String KEY_special_sound = "KEY_special_sound";


const Color APP_main_color = Color(0xffFBD001);
const Color APP_font_grey = Color(0xff666666);
const Color APP_font_deep_grey = Color(0xff999999);
const Color APP_font_black = Color(0xff333333);
const Color APP_verify_error_color = Color(0xffE60012);
const Color APP_divider_color = Color(0xffdddddd);
const Color APP_scaffold_back_color = Color(0xfff9f9f9);

const double ScrollDownBottomHeight = 130;

const String APP_Default_background = "http://zhaota.oss-cn-shenzhen.aliyuncs.com/sys/baihu.png"; // 默认照片墙


TextStyle instanceTextStyle(double fontszie, Color color, {FontWeight fontWeight = FontWeight.normal, TextDecoration decoration = TextDecoration.none}) {
  // Size size = MediaQueryData.fromWindow(window).size;
  // double font = fontszie / 375.0 * size.width;
  return TextStyle(
    fontSize: fontszie.sp,
    color: color,
    fontWeight: fontWeight,
    decoration: decoration
  );
}

bool isLoginPassword(String input) {
  RegExp mobile = new RegExp(r"(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$");
  return mobile.hasMatch(input);
}

Future<dynamic> push(BuildContext context, Widget child) {
  return Navigator.of(context).push(PageTransition(
    child: child,
    curve: Curves.easeInOutExpo,
    type: PageTransitionType.rightToLeft
  ));
}



//转化年龄工具类
class AgeByBirthUtils {
  static String getAge(DateTime brt){
    int age = 0;
    DateTime dateTime = DateTime.now();
    if (!dateTime.isAfter(brt)) { //出生日期晚于当前时间，无法计算
      return '20';
    }
    int yearNow = dateTime.year;  //当前年份
    int monthNow = dateTime.month;  //当前月份
    int dayOfMonthNow = dateTime.day; //当前日期

    int yearBirth = brt.year;
    int monthBirth = brt.month;
    int dayOfMonthBirth = brt.day;
    age = yearNow - yearBirth;   //计算整岁数
    if (monthNow <= monthBirth) {
      if (monthNow == monthBirth) {
        if (dayOfMonthNow < dayOfMonthBirth) age--;//当前日期在生日之前，年龄减一
      } else {
        age--;//当前月份在生日之前，年龄减一
      }
    }
    return age.toString();
  }
}